import {createStore} from 'vuex'
import {$ajax, apiUrl} from "@/utils/request";
import router from "@/router";

export default createStore({
    state: {
        accounts: {},
        routeMenu: []
    },
    getters: {},
    mutations: {
        getAccount() {
            $ajax.get(`${apiUrl}/auth/checkLogin`).then(({data: {result}}) => {
                this.state.accounts = result
            }).catch(() => {
                this.state.accounts = {}
                router.replace({name: "login"})
            })
        },
        getRoute(){
            $ajax.get(`${apiUrl}/administrators/menuList`).then(({data:{result}}) => {
                this.state.routeMenu = result
            })
        }
    },
    actions: {},
    modules: {}
})
